Geeting UnboundLocalError local variable pwd_lable referenced before assignment please guide how to solve this problem so that my program work
I have try to write program for library Management system i am using tkinter module for it. I have write the below code but when i am trying to create multiple Text box i am getting below error please guide ========================================================= File "Hope_work.py", line 22, in __init__ frame = F(container, self) File "Hope_work.py", line 62, in __init__ pwd_lable.pack() UnboundLocalError: local variable 'pwd_lable' referenced before assignment
Below is the complete program i am getting error in Pageone class ========================================================== import tkinter as tk import os
You must be logged in to post. Please login or register an account.
You're typoing.
First you defined it as: pwd_label, then you call it pwd_lable. Fix that :P
-Harrison 7 years ago
You must be logged in to post. Please login or register an account.
oops !!! Thanks for the correction....
-Tathe 7 years ago
You must be logged in to post. Please login or register an account.
The Unboundlocalerror: local variable referenced before assignment is raised when you try to use a variable before it has been assigned in the local context. Python doesn't have variable declarations , so it has to figure out the scope of variables itself. It does so by a simple rule: If there is an assignment to a variable inside a function, that variable is considered local . To solve this problem, you can explicitly say it's a global by putting global declaration in your function. The global statement does not have to be at the beginning of the function definition, but that is where it is usually placed. Wherever it is placed, the global declaration makes a variable to global variable everywhere in the function.
http://net-informations.com/python/err/local.htm
-berkninan 4 years ago
You must be logged in to post. Please login or register an account.